<form action="{:U('Message/send')}" method="post">
	<table type="hidden" class="table table-hover">
		<tfoot>
			<tr>
				<td>&nbsp;</td>
				<td ><input class="btn btn-primary" type="submit" name="submit" value="{:L('SEND')}"/> &nbsp; <input class="btn" onclick="javascript:$('#dialog-send').dialog('close');" type="button" value="{:L('CANCEL')}"/></td>
			</tr>
		</tfoot> 
		<tbody>
			<if condition="$user_info['role_id'] gt 0">
				<input type="hidden" name="to_role_id" value="{$user_info.role_id}" id="to_role_id"/>
			<else />
				<tr>
					<td class="tdleft" width="15%">*{:L('SELECT_THE_RECIPIENT')}</td>
					<td>
						<ul class="nav nav-tabs">
							<volist name="departments_list" id="vo" key="k">
								<li <if condition="$vo['department_id'] eq session('department_id')">class="active"</if>>
									<a class="ta" rel="{$k}" data-toggle="tab">{$vo['name']}</a>
								</li>
							</volist>
						</ul>
						<volist name="departments_list" id="vo" key="k">
							<div class="tab-pane <if condition="$vo['department_id'] neq session('department_id')">hide</if>" id="ta{$k}">
								<input type="checkbox" class="check_all" rel="{$k}"/>{:L('SELECT_ALL')}<br/>
								<volist  name="vo['user']" id="temp">
									<span style="width:33%; float:left;"><input class="muti_role_id{$k}" type="checkbox" name="to_role_id[]" value="{$temp.role_id}"/>{$temp['user_name']}【{$temp.role_name}】&nbsp; </span>
								</volist>
							</div>
						</volist>
					</td>
				</tr>
			</if>
			
			<tr>
				<td class="tdleft">{:L('CONTENTS')}</td>
				<td>
					<textarea rows="5" class="span5" name="content"></textarea>
				</td>
			</tr>
		</tbody>
	</table>
	</form>
<div id="dialog-to-role-list" class="hide" title="{:L('SELECT_THE_RECIPIENT')}">loading...</div>
<script type="text/javascript">
$("#dialog-to-role-list").dialog({
	autoOpen: false,
	modal: true,
	width: 600,
	maxHeight: 400,
	buttons: { 
		"Ok": function () {
			var item = $('input:radio[name="owner"]:checked').val();
			var name = $('input:radio[name="owner"]:checked').parent().next().html();
			$('#to_role_name').val(name);
			$('#to_role_id').val(item);
			$(this).dialog("close"); 
		},
		"Cancel": function () {
			$(this).dialog("close");
		}
	},
	position: ["center", 100]
});
	
$(function(){
	$('#to_role_name').click(
		function(){
			$('#dialog-to-role-list').dialog('open');
			$('#dialog-to-role-list').load("{:U('user/listDialog','by=all')}");
		}
	);
	$('.ta').click(
		function(){
			var num = $(this).attr('rel');
			var list = new Array();
			<volist name="departments_list" id="vo" key="k">
				list.push({$k});
			</volist>
			for (var i=0;i<list.length;i++){
				if(num == list[i]){
					$('#ta'+(i+1)).show();
				}else{
					$('#ta'+(i+1)).hide();
				}
			}
		}
	);
	$('.check_all').click(
		function(){
			var k = $(this).attr('rel');
			$("input[class='muti_role_id"+k+"']").prop('checked', $(this).prop("checked"));
		}
	);
});
</script>